/*
call apply cps
*/
import {call,all,apply,cps} from 'redux-saga/effects';
import {delay, readFile} from '../utils';


//call
/*export function* read():any{
    let result = yield call(delay, 1000, 2000);
    console.log('result', result);
}*/

/*export function* read():any{
    let x = {name:'ahhh'} //x会作为delay函数的this
    let result = yield call([x,delay], 1000, 2000);
    console.log('result', result);
}*/

//apply 和 call一个意思 只是用法不同
/*export function* read(): any {
    let x = {name: 'ahhh'}; //x会作为delay函数的this
    let result = yield apply(x, delay, [1000, 2000]);
    console.log('result', result);
}*/

//想调用node风格的函数使用cps 即回调函数的形式
export function* read(): any {
  const x = {name: 'ahhh'};
  const result = yield cps(readFile,'1.txt');
  console.log('result', result);
}

export default function* rootSaga(): any{
  yield all([read()])
}
